# 任务：在画布上随机位置画出随机图形
# 从 形状 中随机选择形状
# 从 颜色 中随机选择颜色

data='''{
	"turtle": {
		"背景色": "black",
		"图形数目": "20",
		"形状": [
			{
				"形状": "正方形",
				"边长": "30"
			},
			{
				"形状": "五角星",
				"边长": "20"
			}
		],
		"颜色": [
			"green",
			"orange",
			"purple"
		]
	}
}'''
import turtle as t
import random as rd
def draw(bgcolor, colors, count):
	t.bgcolor(bgcolor)
	for n in range(count):
		t.pencolor(rd.choice(colors))
		size = 30
		x = rd.randint(-300, 300)
		y = rd.randint(-300, 300)
		t.penup()
		t.goto(x, y)
		t.pendown()
		shape=rd.choice(['正方形','五角星'])
		if shape=='正方形':
			for m in range(size):
				t.forward(20)
				t.right(90)
		else:
			for m in range(5):
				t.forward(30)
				t.right(144)
colors = ['green','orange','purple']
t.speed("fastest")
draw('black',colors,20) #在一个黑色背景上，随机画50个图形